package petrochina.company.electric.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/**
 * 任务完成提交数据
 */
public class UserInfo implements Parcelable {

    // id
    private long id;

    // 用户状态 0：工人 1：管理员
    private int userType;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getUserType() {
        return userType;
    }

    public void setUserType(int userType) {
        this.userType = userType;
    }

    public static Creator<UserInfo> getCREATOR() {
        return CREATOR;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.id);
        dest.writeInt(this.userType);
    }

    public void readFromParcel(Parcel source) {
        this.id = source.readLong();
        this.userType = source.readInt();
    }

    public UserInfo(long id, int userType) {
        this.id = id;
        this.userType = userType;
    }

    protected UserInfo(Parcel in) {
        this.id = in.readLong();
        this.userType = in.readInt();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof UserInfo)) return false;
        UserInfo that = (UserInfo) o;
        return getId() == that.getId();
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId(), getUserType());
    }

    public static final Creator<UserInfo> CREATOR = new Creator<UserInfo>() {
        @Override
        public UserInfo createFromParcel(Parcel source) {
            return new UserInfo(source);
        }

        @Override
        public UserInfo[] newArray(int size) {
            return new UserInfo[size];
        }
    };
}
